<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>添加评论 - 社交平台</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
</head>
<body>
<jsp:include page="/views/header.jsp"/>

<div class="container mt-4">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h5>添加评论</h5>
                </div>
                <div class="card-body">
                    <div class="post mb-4">
                        <div class="post-header d-flex align-items-center mb-2">
                            <img src="${post.user.avatar != null ? post.user.avatar : 'images/default-avatar.png'}"
                                 class="rounded-circle avatar-sm mr-2" alt="头像">
                            <div>
                                <h6 class="mb-0">${post.user.nickname}</h6>
                                <small class="text-muted">${post.createdAt}</small>
                            </div>
                        </div>
                        <div class="post-content mb-2">
                            <p>${post.content}</p>
                        </div>
                    </div>

                    <form action="${pageContext.request.contextPath}/comment/add" method="post">
                        <input type="hidden" name="postId" value="${post.postId}">
                        <div class="mb-3">
                                <textarea class="form-control" name="content" rows="3"
                                          placeholder="写下你的评论..." required></textarea>
                        </div>
                        <div class="d-flex justify-content-end">
                            <a href="${pageContext.request.contextPath}/post/detail?id=${post.postId}"
                               class="btn btn-outline-secondary me-2">取消</a>
                            <button type="submit" class="btn btn-primary">提交评论</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<jsp:include page="/views/footer.jsp"/>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>